//
//  CommentControl.m
//  WE
//
//  Created by iMacOne on 15/12/1.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "CommentControl.h"
#import "CommentTextCell.h"
#import "Size.h"
#import "ToolUtil.h"
@interface CommentControl ()
{
    UIImageView *imageV;
    UIView *headerView;
}

@end

@implementation CommentControl

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"评论";
    [self.view addSubview:self.tableView];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsZero];
    }

//    self.bottomView.hidden = YES;
//    self.headerView.hidden = YES;
//    self.tableView.frame = CGRectMake(0, 0 ,WindowWidth , WindowHeight);
//    headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, WindowWidth, 200*Height)];
//    headerView.backgroundColor = [UIColor colorWithRed:236/255. green:233/255. blue:215/255. alpha:1.0];
//    
//    imageV = [[UIImageView alloc] initWithFrame:CGRectMake((WindowWidth - 60*Height)/2, 30*Height, 70*Height, 70*Height)];
//    imageV.layer.masksToBounds = YES;
//    imageV.layer.cornerRadius = 30;
//    imageV.image = [UIImage imageNamed:@"111"];
//    [headerView addSubview:imageV];
//    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 110*Height, WindowWidth, 20*Height)];
//    nameLabel.text = @"王实 主治医师";
//    nameLabel.textAlignment = NSTextAlignmentCenter;
//    nameLabel.textColor = [UIColor whiteColor];
//    nameLabel.font = FONT(14);
//    [headerView addSubview:nameLabel];
//    UILabel *numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 140*Height, (WindowWidth - 1)/3, 15*Height)];
//    numberLabel.textColor = [UIColor whiteColor];
//    numberLabel.textAlignment = NSTextAlignmentCenter;
//    numberLabel.font = FONT(12);
//    numberLabel.text = @"22";
//    [headerView addSubview:numberLabel];
//    [ToolUtil createVerticalLine:140*Height superView:headerView lift:(WindowWidth - 1)/3 height:40*Height];
//    UILabel *numberLabel1 = [[UILabel alloc] initWithFrame:CGRectMake((WindowWidth - 1)/3 + 0.5, 140*Height, (WindowWidth - 1)/3, 15*Height)];
//    numberLabel1.textColor = [UIColor whiteColor];
//    numberLabel1.text = @"暂无";
//    numberLabel1.font = FONT(12);
//    numberLabel1.textAlignment = NSTextAlignmentCenter;
//    [headerView addSubview:numberLabel1];
//    [ToolUtil createVerticalLine:140*Height superView:headerView lift:(WindowWidth - 1)/3*2+0.5 height:40*Height];
//    UILabel *numberLabel2 = [[UILabel alloc] initWithFrame:CGRectMake((WindowWidth - 1)/3*2 + 1, 140*Height, (WindowWidth - 1)/3, 15*Height)];
//    numberLabel2.textColor = [UIColor whiteColor];
//    numberLabel2.font = FONT(12);
//    numberLabel2.textAlignment = NSTextAlignmentCenter;
//    numberLabel2.text = @"9.8";
//    [headerView addSubview:numberLabel2];
//    
//    UILabel *orderLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 170*Height, (WindowWidth - 1)/3, 15*Height)];
//    orderLabel.text = @"预约量";
//    orderLabel.textAlignment = NSTextAlignmentCenter;
//    
//    orderLabel.textColor = [UIColor whiteColor];
//    orderLabel.font = FONT(10);
//    [headerView addSubview:orderLabel];
//    
//    UILabel *referLabel = [[UILabel alloc] initWithFrame:CGRectMake((WindowWidth - 1)/3 + 0.5, 170*Height, (WindowWidth - 1)/3, 15*Height)];
//    referLabel.textAlignment = NSTextAlignmentCenter;
//    referLabel.textColor = [UIColor whiteColor];
//    referLabel.text = @"咨询量";
//    referLabel.font = FONT(10);
//    [headerView addSubview:referLabel];
//    
//    UILabel *reviewLabel = [[UILabel alloc] initWithFrame:CGRectMake((WindowWidth - 1)/3*2 + 1, 170*Height, (WindowWidth - 1)/3, 15*Height)];
//    reviewLabel.textColor = [UIColor whiteColor];
//    reviewLabel.font = FONT(10);
//    reviewLabel.textAlignment = NSTextAlignmentCenter;
//    reviewLabel.text = @"患者好评";
//    [headerView addSubview:reviewLabel];
//    self.tableView.tableHeaderView = headerView;
    // Do any additional setup after loading the view.
}
//- (void)viewDidDisappear:(BOOL)animated{
//    [imageV removeFromSuperview];
//}
- (UITableView *)tableView
{
    if (_tableView == nil) {
        self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0 ,WindowWidth , WindowHeight ) style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.showsVerticalScrollIndicator = NO;

    }
    return _tableView;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellIdentifier = @"CommentTextCell";
    
    CommentTextCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[CommentTextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if (indexPath.section == 0) {
//        return <#expression#>
//    }
    return 120;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

//-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//    
//    NSLog(@"%lf",scrollView.contentOffset.y);
//    if (scrollView.contentOffset.y > -20*Height) {//如果当前位移大于缓存位移，说明scrollView向上滑动
//        //
//        float a = 60*Height - (scrollView.contentOffset.y+20*Height);
//        if (a<=30*Height) {
//            imageV.frame = CGRectMake((WindowWidth-30*Height)/2, (44-30*Height)/2, 30*Height, 30*Height);
//            imageV.layer.cornerRadius = 30*Height/2;
//            [self.navigationController.navigationBar addSubview:imageV];
//        }else if(a>30*Height){
//            
//            imageV.frame = CGRectMake((WindowWidth - a)/2, 44*Height + scrollView.contentOffset.y + 20*Height, a, a);
//            imageV.layer.cornerRadius = a/2;
//            [headerView addSubview:imageV];
//            
//        }
//        //self.navigationController.navigationBar.hidden = NO;
//    }
//    
//}

@end
